package com.itheima.controller;

import com.itheima.service.WaterQualityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Validated
public class WaterQualityController {

    @Autowired
    private WaterQualityService waterQualityService;

    // 实时数据
    @GetMapping("/{tableName}/realtime")
    public List<Map<String, Object>> getRealtimeData(@PathVariable String tableName) {
        return waterQualityService.getRealtimeData(tableName);
    }

    @GetMapping("/{tableName}/history")
    public List<Map<String, Object>> getHistoryData(@PathVariable String tableName) {
        return waterQualityService.getHistoryData(tableName);
    }
}

